package com.heima.admin.listener;

import com.heima.admin.service.WemediaNewsAutoScanService;
import com.heima.common.constants.NewsAutoScanConstants;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
public class WemediaNewsAutoListener {

    @Autowired
    WemediaNewsAutoScanService wemediaNewsAutoScanService;

    @KafkaListener(topics = NewsAutoScanConstants.WM_NEWS_AUTO_SCAN_TOPIC)
    public void consumerMessage(ConsumerRecord<?,?>record) throws Exception {
        String value =(String) record.value();
        Integer id = Integer.valueOf(value);
        wemediaNewsAutoScanService.autoScanByMediaNewsId(id);
    }



}
